package com.wss.controller;

import com.wss.domain.Account;
import com.wss.domain.Blog;
import com.wss.domain.Order;
import com.wss.domain.Video;
import com.wss.service.AccountService;
import com.wss.service.BlogService;
import com.wss.service.OrderService;
import com.wss.service.VideoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.util.List;

@Controller
public class UserInfoController {

    @Autowired
    private BlogService blogService;
    @Autowired
    private VideoService videoService;
    @Autowired
    private OrderService orderService;


    @RequestMapping(value="/userInfo")
    public String userInfo(Model model, HttpServletRequest request, HttpServletResponse response) {
        HttpSession session = request.getSession();
        Account account = (Account) session.getAttribute("Account");
        int u_id = account.getId();
        // 我的博客
        List<Blog> blogList = blogService.findBlogByUid(u_id);
        // 我的课程
        List<Video> videoList = videoService.findVideoByUid(u_id);
        // 我的订单
        List<Order> orderList = orderService.findOrderByUid(u_id);
        model.addAttribute("blogList",blogList);
        model.addAttribute("videoList",videoList);
        model.addAttribute("orderList",orderList);
        return "userInfo";
    }


}
